package unibz.thaison.iosa;

import java.util.ArrayList;
import java.util.List;

public class ScreenManager {
	private static ScreenManager singleton;
	
	private ScreenManager() {
		screens.add(new Screen(1, "Screen #1"));
		screens.add(new Screen(2, "Screen #2"));
		screens.add(new Screen(3, "Screen #3"));
		screens.add(new Screen(4, "Screen #4"));
		screens.add(new Screen(5, "Screen #5"));
		screens.add(new Screen(6, "Screen #6"));
		screens.add(new Screen(7, "Screen #7"));
		screens.add(new Screen(8, "Screen #8"));
		screens.add(new Screen(9, "Screen #9"));
		
		services.add(new Service(Service.NO_SERVICE, "No Service"));
		services.add(new Service(Service.SCREEN_STATUS, "Screen Status"));
		services.add(new Service(Service.USERS_SUMMARY, "Users Summary"));
		services.add(new Service(Service.WEATHER, "Weather"));
		services.add(new Service(Service.TRELLO, "Trello board"));
	};
	
	static {
		singleton = new ScreenManager(); 
	}
	
	public static ScreenManager getInstance() {
		return singleton;
	}
	
	private ArrayList<Screen> screens = new ArrayList<Screen>();

	public void addScreen(Screen Screen) {
		screens.add(Screen);
	}
	
	public Screen get(int id) {
		for (int i=0; i<screens.size(); i++) {
			Screen s = screens.get(i);
			if (s.getId() == id) return s;
		}
		return null;
	}
	
	public void delete(int id) {
		for (int i=0; i<screens.size(); i++) {
			Screen s = screens.get(i);
			if (s.getId() == id) {
				screens.remove(i); break;
			}
		}	
	}
	
	public List<Screen> getAll() {
		List<Screen> lst = new ArrayList<Screen>();
		lst.addAll(screens);
		return lst;
	}
	
	public int count() {
		return screens.size();
	}
	
	private ArrayList<Service> services = new ArrayList<Service>();
	
	public List<Service> getServices() {
		return services;
	}
}
